var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  GroupTeamPageView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        WebSocketService.addListener({
          caller: t,
          code: 4199,
          method: t.onGroupTeamDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 41991,
          method: t.onLoadCreateTeamGroupDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4206,
          method: t.onLoadApprovalOptDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4203,
          method: t.onLoadApprovalOptDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4205,
          method: t.onLoadApprovalOptDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4204,
          method: t.onLoadApprovalOptDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 41992,
          method: t.onLoadApprovalOptDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4210,
          method: t.onLoadMultiMyTeamChatDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4215,
          method: t.onLoadFollowTeamOpt,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4211,
          method: t.onLoadTeamList,
        }),
        t.btn_groupTeam_back.on(Laya.Event.CLICK, t, t.onGroupTeamBackAction),
        t.btn_team_zuduixiaoxi.on(
          Laya.Event.CLICK,
          t,
          t.onTeamZuDuiXiaoXiAction
        ),
        t.btn_chuangjianduiwu.on(
          Laya.Event.CLICK,
          t,
          t.onCreateTeamGroupAction
        ),
        t.btn_team_yaoqing.on(Laya.Event.CLICK, t, t.onTeamGroupYaoQingAction),
        t.btn_team_jiesan.on(Laya.Event.CLICK, t, t.onTeamGroupJieSanAction),
        t.btn_team_zuduiList.on(
          Laya.Event.CLICK,
          t,
          t.onAllTeamGroupListAction
        ),
        t.btn_wodexiaodui.on(Laya.Event.CLICK, t, t.onBackMyTeamAction),
        t.list_groupTeam.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickListJoinTeamAction
        ),
        (t.list_groupTeam.renderHandler = new Laya.Handler(
          t,
          t.updateGroupTeamCellItem
        )),
        (t.list_groupTeam.selectEnable = !0),
        (t.list_groupTeam.vScrollBarSkin = ""),
        t.list_myTeamer.on(Laya.Event.CLICK, t, t.onDidClickMyTeamAction),
        (t.list_myTeamer.selectEnable = !0),
        (t.list_myTeamer.renderHandler = new Laya.Handler(
          t,
          t.updateMyTeamCellItem
        )),
        (t.list_myTeamer.vScrollBarSkin = ""),
        t.btn_group_zdsm.on(
          Laya.Event.CLICK,
          t,
          t.onDidGroupZuDuiShuoMingAction
        ),
        t.btn_group_mark.on(Laya.Event.CLICK, t, t.onDidClickGroupMarkAction),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showGroupTeamView = function () {
        return (
          null == this.groupTeamV && (this.groupTeamV = new t()),
          (this.groupTeamV.list_groupTeam.visible = !1),
          this.groupTeamV.initWithView("1"),
          (this.groupTeamV.myIsCaptain = !1),
          (this.groupTeamV.btn_wodexiaodui.visible = !1),
          WebSocketService.send({ c: 4199 }),
          this.groupTeamV
        );
      }),
      (t.prototype.initWithView = function (e) {
        "1" == e
          ? ((this.view_team_main.visible = !0),
            (this.view_team_myTeam.visible = !1),
            (this.view_team_teamList.visible = !1),
            (this.text_team_result.visible = !1),
            (this.list_myTeamer.visible = !1),
            (this.btn_chuangjianduiwu.visible = !0),
            (this.btn_wodexiaodui.visible = !1))
          : "2" == e
          ? ((this.view_team_main.visible = !1),
            (this.view_team_myTeam.visible = !0),
            (this.view_team_teamList.visible = !1),
            (this.text_team_result.visible = !0),
            (this.list_myTeamer.visible = !0),
            (this.btn_chuangjianduiwu.visible = !1))
          : "3" == e &&
            ((this.view_team_main.visible = !1),
            (this.view_team_myTeam.visible = !1),
            (this.view_team_teamList.visible = !0),
            (this.text_team_result.visible = !1),
            (this.list_myTeamer.visible = !1),
            (this.btn_chuangjianduiwu.visible = !1));
      }),
      (t.prototype.updateMyTeamCellItem = function (e, t) {
        var i = e.getChildByName("btn_myTeam_opt"),
          a = e.dataSource;
        1 == a.isCaptain
          ? a.id == Global.roleId
            ? (i.visible = !1)
            : (i.visible = !0)
          : a.roleId == Global.roleId
          ? (i.visible = !1)
          : (i.visible = !0),
          this.myIsCaptain
            ? (i.label = "滚粗")
            : a.roleId == Global.roleId
            ? (i.label = "溜了")
            : 1 == a.isCaptain
            ? (i.label = "追随")
            : (i.label = "溜了");
      }),
      (t.prototype.updateGroupTeamCellItem = function (e, t) {
        var i = e.getChildByName("btn_groupTeam_join");
        e.dataSource
          ? ((i.skin = "comp/commonpic/btn_fayoubao.png"), (i.visible = !0))
          : ((i.skin = ""), (i.visible = !1));
      }),
      (t.prototype.onGroupTeamDataFn = function (e) {
        if (0 == e.code) {
          e.data && e.data.length > 0 && (this.list_myTeamer.visible = !0);
          var t = e.data,
            i = void 0,
            a = [];
          if (t.length > 0) {
            var o = t[0];
            if (
              ((this.label_teamList_name.text = o.userName + "的小队"),
              void 0 != o.value)
            ) {
              for (n = 0; n < t.length; n++) {
                s = t[n];
                this.initWithView("2"),
                  1 == s.isCaptain && Global.roleId == s.roleId
                    ? ((this.myIsCaptain = !0),
                      (this.btn_team_jiesan.visible = !0))
                    : (this.btn_team_jiesan.visible = !1),
                  (this.duiyuanTeamObj = e.data),
                  1 == s.isCaptain &&
                    (this.label_myTeamName.text = s.userName + "的小队"),
                  (i = {
                    label_myTeamer_name: { text: s.lvl + "级 " + s.userName },
                    label_myTeam_gongxian: { text: "贡献：" + s.value },
                    id: s.roleId,
                    isCaptain: s.isCaptain,
                  }),
                  a.push(i);
              }
              (this.list_myTeamer.dataSource = a), this.updateMyTeamViews();
            } else {
              for (var n = 0; n < t.length; n++) {
                var s = t[n];
                this.initWithView("1"),
                  (this.list_groupTeam.visible = !0),
                  (i = {
                    label_team_name: {
                      text: s.captainLvl + "级 " + s.captainUserName + "的小队",
                    },
                    label_teamShows: { text: s.teamShows ? s.teamShows : "" },
                    id: s.captainRoleId,
                  }),
                  a.push(i);
              }
              this.list_groupTeam.dataSource = a;
            }
          }
        }
      }),
      (t.prototype.updateMyTeamViews = function () {
        this.myIsCaptain
          ? ((this.text_team_result.visible = !0),
            (this.btn_group_mark.visible = !0),
            (this.label_xiaoduimubiao.text = "无"))
          : (this.myTeamObj &&
              (this.label_xiaoduimubiao.text = this.myTeamObj.teamShows
                ? this.myTeamObj.teamShows
                : ""),
            (this.text_team_result.visible = !1),
            (this.btn_group_mark.visible = !1));
      }),
      (t.prototype.onTeamGroupJieSanAction = function () {
        WebSocketService.send({ c: 4203 });
      }),
      (t.prototype.onDidClickListJoinTeamAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_groupTeam.selectedItem;
          WebSocketService.send({ c: 4206, d: { roleId: t.id } });
        }
      }),
      (t.prototype.onLoadApprovalOptDataFn = function (e) {
        if ((ToastView.toastView(e.msg), "4203" == e.act_id))
          return (
            this.initWithView("1"),
            void WebSocketService.send({ c: 4210, d: { pageNum: 0 } })
          );
        "4205" == e.act_id
          ? this.initWithView("1")
          : "4204" == e.act_id
          ? WebSocketService.send({ c: 4199 })
          : "41992" == e.act_id && ToastView.toastView(e.msg);
      }),
      (t.prototype.onCreateTeamGroupAction = function () {
        WebSocketService.send({ c: 41991 }),
          WebSocketService.send({ c: 4210, d: { pageNum: 0 } });
      }),
      (t.prototype.onLoadMultiMyTeamChatDataFn = function (e) {
        Laya.stage.event("ChatRoomView", { name: "group_team", data: e.data });
      }),
      (t.prototype.onLoadCreateTeamGroupDataFn = function (e) {
        if (0 == e.code) {
          (this.view_team_myTeam.visible = !0),
            (this.view_team_main.visible = !1),
            (this.view_team_teamList.visible = !1),
            (this.myTeamObj = e.data);
          var t = e.data;
          (this.label_myTeamName.text = e.data.captainUserName + "的小队"),
            (this.text_team_result.visible = !0),
            e.data.teamShows
              ? (this.text_team_result.text = e.data.teamShows)
              : (this.text_team_result.text = ""),
            WebSocketService.send({ c: 4199 }),
            t.captainRoleId == Global.roleId
              ? (this.myIsCaptain = !0)
              : (this.myIsCaptain = !1);
        }
        ToastView.toastView(e.msg);
      }),
      (t.prototype.onDidClickMyTeamAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_myTeamer.selectedItem;
          "btn_myTeam_opt" == e.target.name &&
            ("滚粗" == e.target.label
              ? WebSocketService.send({ c: 4204, d: { roleId: t.id } })
              : "追随" == e.target.label
              ? WebSocketService.send({ c: 4215, d: null })
              : WebSocketService.send({ c: 4205, d: null }));
        }
      }),
      (t.prototype.onTeamGroupYaoQingAction = function () {
        TeamInvitateDialog.showTeamListView();
      }),
      (t.prototype.onDidGroupZuDuiShuoMingAction = function () {
        var e = CaslnoRulesView.showCaslRuleView("zuduishuoming");
        (e.y = 50), (e.height = 570), Laya.stage.addChild(e);
      }),
      (t.prototype.onAllTeamGroupListAction = function () {
        this.initWithView("1"),
          WebSocketService.send({ c: 4211 }),
          this.myIsCaptain
            ? this.myTeamObj &&
              this.myTeamObj.captainRoleId &&
              (this.btn_chuangjianduiwu.visible = !1)
            : this.duiyuanTeamObj && (this.btn_chuangjianduiwu.visible = !1),
          (this.btn_wodexiaodui.visible = !0),
          (this.btn_team_zuduiList.visible = !0);
      }),
      (t.prototype.onBackMyTeamAction = function () {
        this.initWithView("2"), this.updateMyTeamViews();
      }),
      (t.prototype.onDidClickGroupMarkAction = function () {
        var e = this.text_team_result.text;
        e.length > 0
          ? WebSocketService.send({ c: 41992, d: { shows: e } })
          : ToastView.toastView("请先编辑队伍小目标");
      }),
      (t.prototype.onLoadFollowTeamOpt = function (e) {
        ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadTeamList = function (e) {
        if (0 == e.code) {
          if (e.list && e.list.length > 0) {
            (this.list_groupTeam.visible = !0),
              this.initWithView("1"),
              (this.btn_wodexiaodui.visible = !0),
              (this.btn_chuangjianduiwu.visible = !1);
            for (var t = e.list, i = void 0, a = [], o = 0; o < t.length; o++) {
              var n = t[o];
              (i = {
                label_team_name: {
                  text: n.captainLvl + "级 " + n.captainUserName + "的小队",
                },
                label_teamShows: { text: n.teamShows ? n.teamShows : "" },
                id: n.captainRoleId,
              }),
                a.push(i);
            }
            this.list_groupTeam.dataSource = a;
          }
        } else (this.list_groupTeam.visible = !1), ToastView.toastView(e.msg);
      }),
      (t.prototype.onGroupTeamBackAction = function () {
        this.removeSelf();
      }),
      (t.prototype.onTeamZuDuiXiaoXiAction = function () {
        var e = TeamMessageController.openView();
        (e.y = 35), Laya.stage.addChild(e);
      }),
      (t.hideView = function () {
        this.groupTeamV.removeSelf();
      }),
      t
    );
  })(ui.TabBarItemController.GroupTeamPageViewUI);
